
define([], function() {
    'use strict';
    /**
     * PDF Document Class
     * @param {WebPDF.PDFDocType} docType document type
     * @constructor
     */
    var PDFDocument = function(docType) {
        this.docType = docType;
        this.docProperties = null;
        this.pdfPages = [];
    };

    PDFDocument.prototype.getPages = function() {
        return this.pdfPages;
    };
    /**
     * Get page count of the PDF document.
     * @returns {number} page count of the PDF document.
     */
    PDFDocument.prototype.getPageCount = function() {
        return this.pdfPages.length;
    };
    /**
     * Get pdf page by index.
     * @param {number} pageIndex index of the page to get.
     * @returns {WebPDF.IPDFPage} page which specified by given index.
     */
    PDFDocument.prototype.getPage = function(pageIndex) {
        if (isNaN(pageIndex))
            return null;
        return this.pdfPages[pageIndex];
    };
    /**
     * @description Set the type of PDF Document.
     * @param {WebPDF.PDFDocType} docType PDF Document type.
     */
    PDFDocument.prototype.setDocType = function(docType) {
        this.docType = docType;
    };
    /**
     * Get type of PDF document
     * @returns {WebPDF.PDFDocType}
     */
    PDFDocument.prototype.getDocType = function() {
        return this.docType;
    };
    /**
     * Set document properties in JSON format
     * @param {Object} docProperties document properties to set
     */
    PDFDocument.prototype.setDocProperties = function(docProperties) {
        this.docProperties = docProperties;
    };
    /**
     * Get document properties
     * @returns {Object} document properties in JSON format.
     */
    PDFDocument.prototype.getDocProperties = function() {
        return this.docProperties;
    };
    /**
     * add a page to document
     * @param {WebPDF.ImageEngine.PDFPage} pdfPage
     * @private
     */
    PDFDocument.prototype.addPage = function(pdfPage) {
        this.pdfPages.push(pdfPage);
    };
    /**
     * delete page from document
     * @param {number} pageIndex index of page to delete
     * @returns {boolean} return true if delete successfully, otherwise  return false.
     * @private
     */
    PDFDocument.prototype.deletePage = function(pageIndex) {
        if (isNaN(pageIndex) || pageIndex > this.pdfPages.length || pageIndex < 0) {
            return false;
        }
        delete this.pdfPages[pageIndex];
        this.pdfPages.splice(pageIndex, 1);
        return true;
    };
    return PDFDocument;
});